import { defineStore } from 'pinia'
import { computed, ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const token = ref('')

  const getUserToken = computed(() => token.value)

  function watchUserInfo() {
    window.electron.ipcRenderer.on('ipcMainSendUserToken', (_, userInfo) => {
      token.value = userInfo.token
    })
  }

  return {
    getUserToken,
    watchUserInfo
  }
})
